package com.luo.gmall.cart.config;

import com.luo.gmall.cart.exception.AsyncExceptionHandler;
import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.AsyncConfigurer;

import java.util.concurrent.Executor;

/**
 * @author Zoro
 * @date 2021年11月23
 */
@Configuration
public class AsyncConfig implements AsyncConfigurer {

    @Autowired
    private AsyncExceptionHandler asyncExceptionHandler;

    /**
     * 1.初始化线程池
     * 2.根据execute或submit提交执行线程时
     * ① 先判断核心线程数是否已满，
     * ② 判断阻塞队列是否已满
     * ③ 最大可扩展数是否已满
     * ④ 拒绝策略
     * 3.执行后面阻塞队列中的线程
     * 4.判断当前空闲
     *
     * @return
     */
    @Override
    public Executor getAsyncExecutor() {
        return null;
    }

    @Override
    public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() {
        return asyncExceptionHandler;
    }
}
